package logic

import (
	"api/pkg"
	"context"
	"house_srv/house"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type HouseShowLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewHouseShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HouseShowLogic {
	return &HouseShowLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *HouseShowLogic) HouseShow(req *types.HouseShowRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	show, err := l.svcCtx.HouseSrv.HouseShow(l.ctx, &house.HouseShowRequest{
		UserId:  req.UserId,
		HouseId: req.HouseId,
	})
	if err != nil {
		return &types.Response{
			Code:    500,
			Message: pkg.Tri(err.Error()),
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Code:    200,
		Message: "房源详情展示成功",
		Data: map[string]interface{}{
			"UserId":    show.UserId,
			"HouseName": show.HouseName,
			"Price":     show.Price,
			"Floor":     show.Floor,
			"Area":      show.Area,
			"Cover":     show.Cover,
			"Address":   show.Address,
			"Describe":  show.Describe,
		},
	}, nil
}
